package hottargui.config;

import hottargui.framework.*;
import hottargui.standard.*;


public class AlphaBuyState implements TarguiState {

	Game gameContext;
	
	public AlphaBuyState(Game game)
	{
		this.gameContext = game;
	}
	
	public boolean buy(int count, Position deploy) throws IllegalActionException {
	    StandardPlayer player = (StandardPlayer)gameContext.getPlayerInTurn();
	    if (player.getCoins() < count) { return false; }
	    player.withdraw(count);
	    StandardTile tile = (StandardTile)gameContext.getTile(deploy);
	    tile.changeUnitCount(tile.getUnitCount()+count);
	    
	    gameContext.setState(gameContext.getFactory().getEndTurnState(gameContext));
	    return true;
	}

	public State getState() {
		return State.buy;
	}

	public boolean move(Position from, Position to, int count) throws IllegalActionException {
		throw new IllegalActionException(this.getState());
	}

	public void newGame() throws IllegalActionException {
		throw new IllegalActionException(this.getState());
	}

	public void rollDie() throws IllegalActionException {
		throw new IllegalActionException(this.getState());
	}

	public PlayerColor turnCard() throws IllegalActionException {
		throw new IllegalActionException(this.getState());
	}

	public PlayerColor getWinner() throws IllegalActionException {
		throw new IllegalActionException(this.getState());
	}
	
}
